package com.xiangge.supermarket.contronller;

import com.xiangge.supermarket.dao.impl.DaoImpl;
import com.xiangge.supermarket.entity.Member;
import com.xiangge.supermarket.service.impl.ServiceImpl;

import java.util.Scanner;

public class SupermarketController {
    public static final Scanner INPUT = new Scanner(System.in);

    public static final ServiceImpl serviceImpl = new ServiceImpl();
    public static final Member member = new Member();
    public static final DaoImpl daoImpl = new DaoImpl();

    public static void main(String[] args) {
        while (true) {
            System.out.println("===============欢迎来到超市用户管理系统=====================");
            System.out.println("1.查询会员信息");
            System.out.println("2.删除会员");
            System.out.println("3.新增会员信息");
            System.out.println("4.查看所有");
            System.out.println("5.退出");
            System.out.println("======================================================");

            int choice = INPUT.nextInt();
            switch (choice){
                case 1:
                    // 查询会员信息
                    daoImpl.add(member);
                    break ;
                case 2:
                    // 删除会员
                    daoImpl.delete(member.getId());
                    break ;
                case 3:
                    // 新增会员信息
                    System.out.println("请输入您要修改的会员的用户ID：");
                    String id = INPUT.next();
                    System.out.println("请输入新的账号：");
                    String name = INPUT.next();
                    System.out.println("请输入新的卡类型：");
                    String type = INPUT.next();
                    System.out.println("请输入新的积分：");
                    int integration = INPUT.nextInt();
                    System.out.println("请输入新的卡片状态：");
                    String state = INPUT.next();
                    // 封装
                    Member member = new Member(id, name, type, integration, state);
                    daoImpl.update(member);
                    break ;
                case 4:
                    daoImpl.findAll();
                    break;
                default:
                    System.err.println("系统退出！");
                    System.exit(0);
            }
        }
    }
}
